<?php
// +----------------------------------------------------------------------
// | OneKeyAdmin [ Believe that you can do better ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020-2023 http://onekeyadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: MUKE <513038996@qq.com>
// +----------------------------------------------------------------------
namespace plugins\seo\index\listen;

use app\index\model\Config as ConfigModel;

class HtmlCheck
{
    public function handle($response)
    {
        $config  = ConfigModel::getVal('app_seo');
        $html    = '';
        $html   .= ! empty($config['baidu_html_code']) ? "\n".$config['baidu_html_code'] : '';
        $html   .= ! empty($config['google_html_code']) ? "\n".$config['google_html_code'] : '';
        $content = str_replace("<head>", '<head>'.$html, $response->getContent());
        $response->content($content);
    }
}